#include "comm.hpp"

int main()
{
    key_t k = getKey();
    printf("0x%x\n",k);
    int shmid = creatShm(k);
    printf("shmid:%d\n",shmid);

    sleep(5);

    char* start = (char*)attchShm(shmid);
    printf("attach success, adress start: %p\n",start);

    //使用
    while(true)
    {
        shmid_ds ds;
        shmctl(shmid,IPC_STAT,&ds);
        printf("获取信息: size:%d ,pid: %d ,myself: %d",ds.shm_segsz,ds.shm_cpid,getpid());
        printf("client say:%s\n",start);
        sleep(1);
    }

    //去关联
    detachShm(start);

    //删除
    deleteShm(shmid);
    return 0;
}